CC?=gcc
JAVAC=javac

WARN =  -Wall -Wextra -Wshadow -Wbad-function-cast  -Wc++-compat -Wstrict-prototypes -Wformat-security -Wformat-nonliteral -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wfloat-equal -Wundef -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Wpadded
SECU = -fstack-protector -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC
LD = -Wl,-pie,-z,relro
STD = -ansi -pedantic
OPT = -O0
DBG = -ggdb3

CFLAGS?= $(SECU) $(WARN) $(STD) $(OPT) $(DBG) 
LDFLAGS= -lm $(LD)
SRC = perseus.c perseus_test.c perseus_test2.c

OBJ     = $(SRC:.c=.o)
LIBNAME = "libperseus-1.0.6"


all: $(OBJ)
	$(CC) $(CFLAGS) -o $(LIBNAME).so perseus.o -shared
	$(CC) $(CFLAGS) $(LDFLAGS) perseus.o perseus_test.o -o perseus_test 
	$(CC) $(CFLAGS) $(LDFLAGS) perseus.o perseus_test2.o -o perseus_test2

java: $(OBJ)
	cd java && make

%.o   : %.c
	echo " CC $@"
	$(CC) $(CFLAGS) -c -o $@ $<

clean:
	cd java && make clean
	rm -f *.o *.so python/*.pyc perseus_test perseus_test2
